
import { PluginCbType } from '../interface/eventbus.interface';


/**
 * 节流函数
 * @param time 延迟时间
 * @returns 
 */
export function debounceTime(time: number): PluginCbType {
    let timer: any = null;
    return (next: () => void) => {
        if (timer) {
            clearTimeout(timer);
            timer = null;
        }
        timer = setTimeout(() => {
            next();
        }, time)
    }
}
